package com.captjack.thrift;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;

/**
 * @author admin
 */
public class Client {

    public static void main(String[] args) {
        try {
            // 创建 TTransport
            TTransport transport = new TFramedTransport(new TSocket("127.0.0.1", 7003, 1000));
            // 创建 TProtocol
            TProtocol protocol = new TBinaryProtocol(transport);
            // 创建客户端.
            ThriftHelloService.Client client = new ThriftHelloService.Client(protocol);
            // 打开 TTransport
            transport.open();
            long start = System.currentTimeMillis();
            // 调用服务方法
            for (int i = 0; i < 10000; i++) {
                String result = client.helloString("asgsg");
            }
            System.out.println(System.currentTimeMillis() - start);
            transport.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
